package com.lmx.repoDomain.tmodel;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiLookupIncludeAutomatically;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

@JsonApiResource(type = "nursingplanexe")
@Table(name = "tnb_nursingplanexe")
@Entity
public class NursingPlanExecute extends BaseEntity {

	private static final long serialVersionUID = 1L;

	private User recordUser;

	private String remark;// 备注

	private Employee exeStaff;// 执行者

	private Integer exeStartTime;// 开始时间

	private Integer exeEndTime;// 完成时间

	private NursingPlan plan;//

	private NursingProjectServiceItem itemProject;//

	private NursingPlanServiceItem itemPlan;//

	private Integer createDateTime;

	private NursingPlanDetail detail;

	private Dicttype exeStatus;

	private Customer recorder;

	private Integer realMoneyCost;

	private Integer realPointCost;

	private Integer pointIncrease;

	private String planExeDate;// 计划执行时间

	private ServiceFinishLevel finishLevel;// old:完成情况标签 new: 完成状态
	
	private Set<NursingServiceItemSign> signs;
	
	private String exeTabRemark;// 执行情况标签

	private HbeaconWarning warning;
	
	@JsonApiToOne
	@JsonApiLookupIncludeAutomatically
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "warning_id", foreignKey = @ForeignKey(name = "null"))
	public HbeaconWarning getWarning() {
		return warning;
	}

	public void setWarning(HbeaconWarning warning) {
		this.warning = warning;
	}

	@Column(name = "exe_tab_remark")
	public String getExeTabRemark() {
		return exeTabRemark;
	}

	public void setExeTabRemark(String exeTabRemark) {
		this.exeTabRemark = exeTabRemark;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "finishLevel_id", foreignKey = @ForeignKey(name = "null"))
	public ServiceFinishLevel getFinishLevel() {
		return finishLevel;
	}

	public void setFinishLevel(ServiceFinishLevel finishLevel) {
		this.finishLevel = finishLevel;
	}

	@Column(name = "plan_exedate")
	public String getPlanExeDate() {
		return planExeDate;
	}

	public void setPlanExeDate(String planExeDate) {
		this.planExeDate = planExeDate;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "nursingplan_detail_id", foreignKey = @ForeignKey(name = "null"))
	public NursingPlanDetail getDetail() {
		return detail;
	}

	public void setDetail(NursingPlanDetail detail) {
		this.detail = detail;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "plan_serviceitem_id", foreignKey = @ForeignKey(name = "null"))
	public NursingPlanServiceItem getItemPlan() {
		return itemPlan;
	}

	public void setItemPlan(NursingPlanServiceItem itemPlan) {
		this.itemPlan = itemPlan;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "project_serviceitem_id", foreignKey = @ForeignKey(name = "null"))
	public NursingProjectServiceItem getItemProject() {
		return itemProject;
	}

	public void setItemProject(NursingProjectServiceItem itemProject) {
		this.itemProject = itemProject;
	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "nursingplan_id", foreignKey = @ForeignKey(name = "null"))
	public NursingPlan getPlan() {
		return plan;
	}

	public void setPlan(NursingPlan plan) {
		this.plan = plan;
	}

	@Column(name = "exeendtime")
	public Integer getExeEndTime() {
		return exeEndTime;
	}

	public void setExeEndTime(Integer exeEndTime) {
		this.exeEndTime = exeEndTime;
	}

	@Column(name = "exestarttime")
	public Integer getExeStartTime() {
		return exeStartTime;
	}

	public void setExeStartTime(Integer exeStartTime) {
		this.exeStartTime = exeStartTime;
	}

	@JsonApiToOne
	@JsonApiLookupIncludeAutomatically
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "exeuser_id", foreignKey = @ForeignKey(name = "null"))
	public Employee getExeStaff() {
		return exeStaff;
	}

	public void setExeStaff(Employee exeStaff) {
		this.exeStaff = exeStaff;
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "exe_status_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getExeStatus() {
		return exeStatus;
	}

	public void setExeStatus(Dicttype exeStatus) {
		this.exeStatus = exeStatus;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "record_id", foreignKey = @ForeignKey(name = "null"))
	public Customer getRecorder() {
		return recorder;
	}

	public void setRecorder(Customer recorder) {
		this.recorder = recorder;
	}

	@Column(name = "real_money_cost")
	public Integer getRealMoneyCost() {
		return realMoneyCost;
	}

	public void setRealMoneyCost(Integer realMoneyCost) {
		this.realMoneyCost = realMoneyCost;
	}

	@Column(name = "real_point_cost")
	public Integer getRealPointCost() {
		return realPointCost;
	}

	public void setRealPointCost(Integer realPointCost) {
		this.realPointCost = realPointCost;
	}

	@Column(name = "point_increase")
	public Integer getPointIncrease() {
		return pointIncrease;
	}

	public void setPointIncrease(Integer pointIncrease) {
		this.pointIncrease = pointIncrease;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "record_user_id", foreignKey = @ForeignKey(name = "null"))
	public User getRecordUser() {
		return recordUser;
	}

	public void setRecordUser(User recordUser) {
		this.recordUser = recordUser;
	}

	@JsonApiToMany
	@JsonApiIncludeByDefault
	@Fetch(FetchMode.JOIN)
	@ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinTable(name = "rel_nursing_exe_sign", joinColumns = { @JoinColumn(name = "exe_id") }, inverseJoinColumns = {
			@JoinColumn(name = "sign_id") })
	public Set<NursingServiceItemSign> getSigns() {
		return signs;
	}

	public void setSigns(Set<NursingServiceItemSign> signs) {
		this.signs = signs;
	}

}
